using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using BUS;
using Entities;
using Utility;

public partial class Admin_NguoiDung_CapNhatDoanhNghiep : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {

            LoadData();
        }
    }
    private void LoadData()
    {
        try
        {
            int id = int.Parse(Request.QueryString["id"].ToString());
            tbDoanhNghiep doanhnghiep = tbDoanhNghiepBUS.GetByID(id);
            if (doanhnghiep!= null)
            {
                txt_MaDoanhNghiep.Text = id.ToString();
                txt_TenDoanhNghiep.Text = doanhnghiep.TenDN;
                txt_DiaChi.Text = doanhnghiep.DiaChi;
                txt_DienThoai.Text = doanhnghiep.DienThoai;
                txt_Email.Text = doanhnghiep.Email;
                txt_MatKhau.Text = doanhnghiep.MatKhau;
                txt_MaTK.Text = doanhnghiep.MaTK;
            }
        }
        catch
        {
            Response.Redirect("~/Admin/NguoiDung/DanhSachDoanhNghiep.aspx");
        }

    }
    protected void btn_luu_Click(object sender, EventArgs e)
    {
        try
        {
            tbDoanhNghiep doanhnghiep = new tbDoanhNghiep();
            doanhnghiep.MaDN = int.Parse(txt_MaDoanhNghiep.Text);
            doanhnghiep.TenDN = txt_TenDoanhNghiep.Text;
            doanhnghiep.DiaChi = txt_DiaChi.Text;
            doanhnghiep.DienThoai = txt_DienThoai.Text;
            doanhnghiep.Email = txt_Email.Text;
            doanhnghiep.MatKhau = txt_MatKhau.Text;
            doanhnghiep.MaTK = txt_MaTK.Text;
            tbDoanhNghiepBUS.UpDate(doanhnghiep);
        }
        catch
        {
            Response.Redirect("~/Admin/NguoiDung/DanhSachDoanhNghiep.aspx");
        }
        Response.Redirect("~/Admin/NguoiDung/DanhSachDoanhNghiep.aspx");

    }
}
